<template>
  <i-tab-bar :current="current" fixed="true" color="#f759ab" @change="handleChange">
    <i-tab-bar-item key="integral" icon="integral" current-icon="integral" size="28"></i-tab-bar-item>
    <i-tab-bar-item key="emoji" icon="emoji" current-icon="emoji" size="50"></i-tab-bar-item>
    <i-tab-bar-item key="addressbook" icon="addressbook" current-icon="addressbook" size="28"></i-tab-bar-item>
  </i-tab-bar>
</template>

<script>
  export default {
    props: ['current'],
    data() {
      return {
        current: 'addressbook'
      }
    },
    mounted() {
      let self = this
      wx.getStorage({
        key: 'currentPage',
        success(res) {
          let mp = {'detail': {'key': res.data}}
          self.handleChange({mp})
        }
      })
    },
    methods: {
      getUserInfo() {
        // 调用登录接口
        wx.login({
          success: () => {
            wx.getUserInfo({
              success: (res) => {
                this.userInfo = res.userInfo
              }
            })
          }
        })
      },
      handleChange({mp}) {
        let currentBar = mp.detail.key
        this.current = currentBar
        wx.setStorage({
          key: 'currentPage',
          data: currentBar
        })
        let url = ''
        switch (currentBar) {
          case 'addressbook':
            url = 'index'
            break
          case 'emoji':
            url = ''
            break
          case 'integral':
            url = 'home'
            break
        }
        this.$router.push(url)
      }
    }
  }
</script>

<style>

</style>
